//Form validation: doInit
function initFormValidation(){
	userName = dojo.byId("userName").value;
	userNickname = dojo.byId("userNickname").value;
	userPassword = dojo.byId("userPassword").value;
	var nameFlg = true;
	var nickFlg = true;
	var pwdFlg = true;
	var sameFlg = true;
	var errMsg = "";
	if(userName.length<2){
		errMsg = "UserName is too short!<br>";
		nameFlg = false;
	}
	if(userNickname.length<2){
		nickFlg = false;
		errMsg+="UserNickname is too short!<br>";
	}
	if(userPassword.length<6){
		pwdFlg = false;
		errMsg+="Password is too short, please input 6 words at least"
	}
	if(nameFlg&&nickFlg){
		if(userName == userPassword || userNickname == userPassword){
			sameFlg = false;
			errMsg+="The password can't be same with userName or userNickname!<br>";
		}
	}
	if(!(nameFlg&&nickFlg&&sameFlg)){
		return errMsg; 
	}else{
		return null;
	}
}

function loginFormValidation(){
	return  null;
}

function decrypt(cipher){	
	var message = AESUtil.decrypt(
		user.name, user.password, cipher);
	return message;
}
function encrypt(message){
	var cipher = AESUtil.encrypt(
		user.name, user.password, message);
	return cipher;
}
